/* 
 * File:   image.hpp
 * Author: gustavo
 *
 * Created on August 28, 2012, 2:22 AM
 */

#ifndef IMAGE_HPP
#define	IMAGE_HPP

#include "../math/matrix.hpp"

namespace imp {
	namespace img {

		//		enum ImageType {
		//			GRAY = 0,
		//			RGB
		//		};

		template <typename T> class Image : public math::Matrix<T> {
			/////
		public:
			int width;
			int height;
			long int npixels;
			int nchannels;

		public:
			Image(int width, int height, int channels, int stride);
			Image(int width, int height, int channels = 1);
			Image();
			virtual ~Image();

		public:
			void setSize(int width, int height, int channels);

		};

		template <typename T> Image<T>::Image(int width, int height, int channels, int stride) : math::Matrix<T>(height, width*channels, stride) {
			this->width = width;
			this->height = height;
			this->npixels = width*height;
			this->nchannels = channels;
		}

		template <typename T> Image<T>::Image(int width, int height, int channels) : math::Matrix<T>(height, width*channels) {
			this->width = width;
			this->height = height;
			this->npixels = width*height;
			this->nchannels = channels;
		}

		template <typename T> Image<T>::Image() : math::Matrix<T>() {
			this->width = 0;
			this->height = 0;
			this->npixels = 0;
			this->nchannels = 0;
		}

		template <typename T> Image<T>::~Image() {
		}

		template <typename T> void Image<T>::setSize(int width, int height, int channels) {
			this->release();

			this->width = width;
			this->height = height;
			this->npixels = width*height;
			this->nchannels = channels;

			this->setSize(height, width * channels);
		}

	}

}

#endif	/* IMAGE_HPP */

